/* eslint-disable */

(function () {
  function GetRequest() {
    var e = location.href;
    var f = {};
    if (e.indexOf("?") != -1) {
      var g = e.substr(e.indexOf("?") + 1);
      g = g.split("&");
      for (var h = 0; h < g.length; h++) {
        f[g[h].split("=")[0]] = decodeURI(g[h].split("=")[1]);
      }
    }
    return f;
  }
  var myurl = window.location.href;
  var openid = GetRequest().openId;
  wx.ready(function () {
    var title = "小鱼向前冲冲冲！10万元话费券等你来~";
    var descT = "赢大奖的时候到啦~冲鸭~";
    var desc = "小鱼向前冲冲冲！10万元话费券等你来~";
    // var link =
    // 'http://open.weixin.qq.com/connect/oauth2/authorize?appid=wx22a6154dfb9e6b4f&
    // r
    // edirect_uri=https://epay.10010.com/wxservice/woqianbao.jsp&response_type=code
    // & scope=snsapi_base&state=STATE&connect_redirect=1#wechat_redirect';
    var link = 'http://wkfw.unisk.cn/openwx/game/wqbgame_id/7jvk2KSkPgZh1Vbo';
    var imgUrl = "http://wkfw.unisk.cn/woqianbao/fishup/static/images/title.png";
    //分享到朋友圈
    wx.onMenuShareTimeline({
      title: title, // 分享标题【必填】
      desc: desc, // 分享描述【必填】
      link: link, // 分享链接【必填】
      imgUrl: imgUrl, // 分享图标【必填】
      success: function () {
        // 用户确认分享后执行的回调函数 shareNum();
      },
      cancel: function () {
        // 用户取消分享后执行的回调函数
      }
    });

    //分享给好友
    wx.onMenuShareAppMessage({
      title: title, // 分享标题【必填】
      desc: descT, // 分享描述【必填】
      link: link, // 分享链接【必填】
      imgUrl: imgUrl, // 分享图标【必填】
      type: 'link', // 分享类型,music、video或link，不填默认为link【必填】
      dataUrl: '', // 如果type是music或video，则要提供数据链接，默认为空
      success: function () {
        // 用户确认分享后执行的回调函数
        $('.share').css({'display': 'none'});
      },
      cancel: function () {
        // 用户取消分享后执行的回调函数
      }
    });

  });

  var appId = "wx22a6154dfb9e6b4f";
  var noncestr = "oDxlNmsjqvV9D29r"; //随意
  var timestamp = "1420942347"; //随意
  var signature = null;
  $.ajax({
    url: 'http://wkfw.unisk.cn/api/woqianbao/fishup/getSignatureJson',
    async: false,
    dataType: "json",
    data: {
      "noncestr": noncestr,
      "timestamp": timestamp,
      "url": myurl
    },
    success: function (data) {
      if (data.code == 200) {
        signature = data.res;
        // console.log("noncestr=" + noncestr + "timestamp=" + timestamp + "url=" +
        // myurl + "signature=" + signature);
      } else {
        signature = "error";
      }
    },
    error: function () {
      signature = "error";
    }
  });
  wx.config({
    debug: false,
    appId: appId,
    timestamp: timestamp,
    nonceStr: noncestr,
    signature: signature,
    jsApiList: [
      'checkJsApi',
      'onMenuShareTimeline',
      'onMenuShareAppMessage',
      'onMenuShareQQ',
      'onMenuShareWeibo',
      'hideMenuItems',
      'showMenuItems',
      'hideAllNonBaseMenuItem',
      'showAllNonBaseMenuItem',
      'translateVoice',
      'startRecord',
      'stopRecord',
      'onRecordEnd',
      'playVoice',
      'pauseVoice',
      'stopVoice',
      'uploadVoice',
      'downloadVoice',
      'chooseImage',
      'previewImage',
      'uploadImage',
      'downloadImage',
      'getNetworkType',
      'openLocation',
      'getLocation',
      'hideOptionMenu',
      'showOptionMenu',
      'closeWindow',
      'scanQRCode',
      'chooseWXPay',
      'openProductSpecificView',
      'addCard',
      'chooseCard',
      'openCard'
    ]
  });

})();